﻿<%@ Page Title="" Language="C#" Theme="Default_Themes" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="QuanLyTinTuc.aspx.cs" Inherits="DanhMuc_QuanLyTinTuc" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit.HTMLEditor" TagPrefix="HTMLEditor" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    <asp:UpdatePanel ID="udt1" runat="server">
        <ContentTemplate>
            <asp:Panel ID="pnmanager" runat="server">
                 <div class="row-fluid">
                    <div class="span12">
                        <div class="box" style="border:1px solid #B6D1F2;" >
                            <div class="box-title">
                                <h3><i class="icon-file"></i>Quản lý tin tức - Thông báo</h3>
                                <div style="float:right;">
                                    <asp:LinkButton ID="LinkButton1" Visible="true" runat="server" class="btn btn-danger" OnClick="LinkButton1_Click" OnClientClick="return confirm('Bạn có chắc xóa không?')"><i class="icon-remove"></i> Xóa</asp:LinkButton>
                                    <asp:LinkButton ID="btn_addnews" Visible="true" runat="server" class="btn btn-warning" OnClick="btn_addnews_Click"><i class="icon-file-text-alt"></i> Đăng tin mới</asp:LinkButton>
                                </div>
                            </div>
                            <div class="box-content">
                                <div id="dvScreenWidth" visible="false"></div> <!--Thanh cuon ngang-->
                                <div class="GridDock" id="dvGridWidth"> <!--Thanh cuon ngang-->
                                    <asp:GridView ID="grid_news" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" Width="100%" CellPadding="4" ForeColor="#333333" GridLines="None" Style="margin-top: 0px" DataKeyNames="ID" PageSize="20" OnRowDataBound="grid_news_RowDataBound" OnRowDeleting="grid_news_RowDeleting" OnRowCommand="grid_news_RowCommand">
                                        <AlternatingRowStyle BackColor="White" />
                                        <Columns>
                                            <asp:TemplateField HeaderText="Chọn ">
                                                <HeaderTemplate>
                                                    <asp:CheckBox ID="chkselectAll" runat="server" OnCheckedChanged="chkInGridviewHeader_CheckedChanged" AutoPostBack="true" />
                                                </HeaderTemplate>
                                                <ItemTemplate>
                                                    <asp:CheckBox ID="chkchon" Enabled="true" Checked="false" runat="server" />
                                                </ItemTemplate>
                                                <ItemStyle CssClass="ItemGridCell" HorizontalAlign="Center" VerticalAlign="Middle" />
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="Tiêu đề">
                                                <ItemTemplate>
                                                    <%#Eval("Title") %>
                                                </ItemTemplate>
                                                <ItemStyle CssClass="ItemGridCell" HorizontalAlign="Left" VerticalAlign="Middle" />
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="Người đăng">
                                                <ItemTemplate>
                                                    <%#Eval("NguoiDang") %>
                                                </ItemTemplate>
                                                <ItemStyle CssClass="ItemGridCell" HorizontalAlign="Left" VerticalAlign="Middle" />
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="Ngày đăng">
                                                <ItemTemplate>
                                                    <%#Eval("NgayDang") %>
                                                </ItemTemplate>
                                                <ItemStyle CssClass="ItemGridCell" HorizontalAlign="Center" VerticalAlign="Middle" />
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="Xóa">
                                                <ItemTemplate>
                                                    <asp:LinkButton ID="LinkButtonxoa" runat="server" CausesValidation="false" CommandName="Delete" Text="<i class='icon-remove red'></i> Xóa" OnClientClick="return confirm('Bạn có chắc xóa không?')"></asp:LinkButton>
                                                </ItemTemplate>
                                                <ItemStyle CssClass="ItemGridCell" HorizontalAlign="Center" VerticalAlign="Middle" />
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="Sửa">
                                                <ItemTemplate>
                                                    <asp:LinkButton ID="LinkButtonEdit" runat="server" CausesValidation="false" CommandName="EditNews" CommandArgument='<%#Eval("ID") %>' Text="<i class='icon-edit'></i> Sửa"></asp:LinkButton>
                                                </ItemTemplate>
                                                <ItemStyle CssClass="ItemGridCell" HorizontalAlign="Center" VerticalAlign="Middle" />
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="Loại tin">
                                                <ItemTemplate>
                                                    trang thai o day se hien thi bang hinh anh
                                                </ItemTemplate>
                                                <ItemStyle CssClass="ItemGridCell" HorizontalAlign="Center"/>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="Loai" Visible="False"> <%--them cho nay de lay cac gia tri trang thai--%>
                                                <ItemTemplate>
                                                    <asp:Label ID="lblloai" runat="server" Text=' <%#Eval("Loai") %>'></asp:Label>
                                                </ItemTemplate>
                                                <ItemStyle CssClass="ItemGridCell" HorizontalAlign="Center" VerticalAlign="Middle" />
                                            </asp:TemplateField>
                                        </Columns>
                                        <EditRowStyle BackColor="#2461BF" />
                                        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                                        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                                        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                                        <RowStyle BackColor="#EFF3FB" />
                                        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                                        <SortedAscendingCellStyle BackColor="#F5F7FB" />
                                        <SortedAscendingHeaderStyle BackColor="#6D95E1" />
                                        <SortedDescendingCellStyle BackColor="#E9EBEF" />
                                        <SortedDescendingHeaderStyle BackColor="#4870BE" />
                                    </asp:GridView>
                                </div>
                                <div class="" style="float:right;display:inline-block;width:auto;">
                                    <asp:LinkButton ID="btn_LocXemTatCa" runat="server" Text="<button class='btn btn-circle btn-inverse  show-tooltip' data-original-title='Xem tất cả đoàn viên bị xóa'><i class='icon-home'></i></button> Tất cả đoàn viên" ForeColor="#444444" OnClick="btn_LocXemTatCa_Click"></asp:LinkButton>&nbsp; &nbsp;
                                    <button class='btn btn-circle btn-success show-tooltip' data-original-title='Tin tức'><i class='icon-file-text-alt'></i></button>&nbsp;<asp:LinkButton ID="linkDoanVien" runat="server" ForeColor="#15b74e" OnClick="linkDoanVien_Click">Tin tức</asp:LinkButton>&nbsp;&nbsp;
                                    <button class='btn btn-circle  btn-primary show-tooltip' data-original-title='Thông báo'><i class= 'icon-envelope-alt'></i></button>&nbsp;<asp:LinkButton ID="linkDoanVienTruongThanh" runat="server" ForeColor="#0090ff" OnClick="linkDoanVienTruongThanh_Click">Thông báo</asp:LinkButton>&nbsp;&nbsp;
                                </div>
                                <div class="clearfix"></div>
                            </div>
                        </div>
                    </div>
                </div>
            </asp:Panel>
            <asp:Panel ID="pneditnews" runat="server" Visible="false">
                <input type="hidden" runat="server" id="txtid" />
                 <div class="row-fluid">
                    <div class="span12">
                        <div class="box" style="border:1px solid #B6D1F2;" >
                            <div class="box-title">
                                <h3><i class="icon-file"></i><asp:Label ID="lbltitle" runat="server"></asp:Label></h3>
                            </div>
                            <div class="box-content">
                                <div class="control-group info">
                                    <div style="float:left;width:73%;">
                                        <label class="control-label" style="width: 150px; padding-right: 10px;">Tiêu đề</label>
                                    <div class="controls">
                                        <asp:TextBox ID="txttitle" runat="server"  CssClass="span6" onblur="KiemTraInjection(this);"></asp:TextBox>
                                    </div>
                                    <div style="height:5px;"></div>
                                    <label class="control-label" style="width: 150px; padding-right: 10px;">Tin tức - thông báo</label>
                                    <div class="controls">
                                        <asp:RadioButton ID="tintuc" runat="server" CssClass="radio inline" Checked="true" Text="Tin tức" GroupName="new" />
                                        <asp:RadioButton ID="thongbao" runat="server" CssClass="radio inline" Text="Thông báo" GroupName="new" />
                                    </div>
                                    <div style="height:5px;"></div>
                                    <label class="control-label" style="width: 150px; padding-right: 10px;">Gủi đến</label>
                                    <div class="controls">
                                        <asp:RadioButton ID="rdball" runat="server" CssClass="radio inline" Checked="true" AutoPostBack="true" OnCheckedChanged="rdball_CheckedChanged" Text="Tất cả đơn vị" GroupName="select" />
                                        <asp:RadioButton ID="drbselect" runat="server" CssClass="radio inline" Text="Chọn đơn vị" GroupName="select" AutoPostBack="true" OnCheckedChanged="rdball_CheckedChanged"/>
                                    </div>
                                    <div class="clearfix" style="height:5px;"></div>
                                        <HTMLEditor:Editor runat="server" Id="editor" Height="300px" AutoFocus="true" Width="100%" />
                                        <asp:LinkButton ID="btnadd" class="btn btn-primary"  runat="server" Width="60px" OnClick="btnadd_Click"><i class="icon-save"></i>&nbsp;&nbsp;Lưu</asp:LinkButton>
                                        
                                        <asp:LinkButton ID="btnclose" Visible="true" runat="server" class="btn  btn-danger" OnClick="btnclose_Click"><i class="icon-signout"></i> Đóng</asp:LinkButton>
                                        <asp:Label ID="lblmessage" runat="server" Visible="false" ForeColor="Red"></asp:Label>
                                        <asp:Label ID="lblstatus" runat="server" Visible="false" Text=""></asp:Label>
                                    </div>
                                    <div style="float:right;width:25%">
                                        <asp:Panel ID="pndonvi" runat="server" Visible="false">
                                        <fieldset>
                                        <legend>Chọn đơn vị</legend>
                                            <%--phan bo duoi dung trong truong hop lay gia tri chua node khi checked hoat unchecked--%>
                                       <%-- <asp:TreeView ID="TreeView1" runat="server" ShowLines="True" ShowCheckBoxes="All" OnTreeNodeCheckChanged="TreeView1_TreeNodeCheckChanged" onclick=" __doPostBack('','');">
                                            <SelectedNodeStyle Font-Italic="True" Font-Underline="False" ForeColor="#006600" Font-Bold="True" />
                                        </asp:TreeView>--%>
                                        <%--neu su dung treeview duoi day va phan javascript ben duoi thi cho phem check tat ca cac node con khi node cha duoc check--%>
                                        <%--<asp:TreeView ID="TreeView1" runat="server" ShowCheckBoxes="All" ExpandDepth="0"   AfterClientCheck="CheckChildNodes();" PopulateNodesFromClient="true" ShowLines="true" ShowExpandCollapse="true" onclick="OnTreeClick(event)"> </asp:TreeView>--%>
                                        <asp:TreeView ID="TreeView1" runat="server" ShowCheckBoxes="All" ShowLines="true"> </asp:TreeView>
                                    </fieldset>
                                            </asp:Panel>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </asp:Panel>
        </ContentTemplate>
    </asp:UpdatePanel>
    <asp:UpdateProgress ID="udtprogress" runat="server" AssociatedUpdatePanelID="udt1">
        <ProgressTemplate>
            <div class="progress">
                <img src="../img/ajax-loader.gif" />
            </div>
        </ProgressTemplate>
    </asp:UpdateProgress>  
    <script type="text/javascript">
        $(document).ready(function () {
            $('#dvGridWidth').width($('#dvScreenWidth').width());
        });
    </script>


    <%--<script type="text/javascript">
        function OnTreeClick(evt) {
            var src = window.event != window.undefined ? window.event.srcElement : evt.target;
            var isChkBoxClick = (src.tagName.toLowerCase() == "input" && src.type == "checkbox");
            if (isChkBoxClick) {
                var parentTable = GetParentByTagName("table", src);
                var nxtSibling = parentTable.nextSibling;
                if (nxtSibling && nxtSibling.nodeType == 1)//check if nxt sibling is not null & is an element node
                {
                    if (nxtSibling.tagName.toLowerCase() == "div") //if node has children
                    {
                        //check or uncheck children at all levels
                        CheckUncheckChildren(parentTable.nextSibling, src.checked);
                    }
                }
                //check or uncheck parents at all levels
                CheckUncheckParents(src, src.checked);
            }
        }

        function CheckUncheckChildren(childContainer, check) {
            var childChkBoxes = childContainer.getElementsByTagName("input");
            var childChkBoxCount = childChkBoxes.length;
            for (var i = 0; i < childChkBoxCount; i++) {
                childChkBoxes[i].checked = check;
            }
        }

        function CheckUncheckParents(srcChild, check) {
            var parentDiv = GetParentByTagName("div", srcChild);
            var parentNodeTable = parentDiv.previousSibling;

            if (parentNodeTable) {
                var checkUncheckSwitch;

                if (check) //checkbox checked
                {
                    var isAllSiblingsChecked = AreAllSiblingsChecked(srcChild);
                    if (isAllSiblingsChecked)
                        checkUncheckSwitch = true;
                    else
                        return; //do not need to check parent if any(one or more) child not checked
                }
                else //checkbox unchecked
                {
                    checkUncheckSwitch = false;
                }

                var inpElemsInParentTable = parentNodeTable.getElementsByTagName("input");
                if (inpElemsInParentTable.length > 0) {
                    var parentNodeChkBox = inpElemsInParentTable[0];
                    parentNodeChkBox.checked = checkUncheckSwitch;
                    //do the same recursively
                    CheckUncheckParents(parentNodeChkBox, checkUncheckSwitch);
                }
            }
        }

        function AreAllSiblingsChecked(chkBox) {
            var parentDiv = GetParentByTagName("div", chkBox);
            var childCount = parentDiv.childNodes.length;
            for (var i = 0; i < childCount; i++) {
                if (parentDiv.childNodes[i].nodeType == 1) //check if the child node is an element node
                {
                    if (parentDiv.childNodes[i].tagName.toLowerCase() == "table") {
                        var prevChkBox = parentDiv.childNodes[i].getElementsByTagName("input")[0];
                        //if any of sibling nodes are not checked, return false
                        if (!prevChkBox.checked) {
                            return false;
                        }
                    }
                }
            }
            return true;
        }

        //utility function to get the container of an element by tagname
        function GetParentByTagName(parentTagName, childElementObj) {
            var parent = childElementObj.parentNode;
            while (parent.tagName.toLowerCase() != parentTagName.toLowerCase()) {
                parent = parent.parentNode;
            }
            return parent;
        }

</script>--%>

    <br><br><br><br><br><br><br><br><br><br><br><br>
    <br><br><br><br><br><br><br><br><br><br><br><br>
</asp:Content>

